package com.lantosec.hmrp.modules.supplier.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.lantosec.hmrp.core.mvc.BaseEntity;
import com.lantosec.hmrp.modules.supplier.vo.SupplierAccessoryVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.web.multipart.MultipartFile;

import java.util.Date;

/**
 * <p>
 * 供应商附件信息 实体类
 * </p>
 *
 * @author AutoCode
 * @since 2020-02-20
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SupplierAccessory extends BaseEntity<SupplierAccessoryVO> {

    private static final long serialVersionUID = 1L;

    public SupplierAccessory(SupplierAccessoryVO vo) {
        this.accessoryId = vo.getAccessoryId();
        this.supplierCode = vo.getSupplierCode();
        this.accessoryType = vo.getAccessoryType();
        this.uploadId = vo.getUploadId();
        this.accessoryName = vo.getAccessoryName();
        this.validityBeginDate = vo.getValidityBeginDate();
        this.validityEndDate = vo.getValidityEndDate();
        this.createTime = vo.getCreateTime();
        this.crateUserId = vo.getCrateUserId();
        this.createUser = vo.getCreateUser();
    }

    @Override
    public SupplierAccessoryVO convertToVO() {
        return new SupplierAccessoryVO(this);
    }


    /**
     * 附件ID
     */
    @TableId(value = "accessory_id", type = IdType.ASSIGN_UUID)
    private String accessoryId;

    /**
     * 供应商编码
     */
    private String supplierCode;

    /**
     * 附件类型，对应字典表ID
     */
    private String accessoryType;

    /**
     * 上传附件表ID
     */
    private String uploadId;

    /**
     * 附件名称
     */
    private String accessoryName;

    /**
     * 有效期开始日期(yyyy-MM-dd)
     */
    private String validityBeginDate;

    /**
     * 有效期结束日期(yyyy-MM-dd)
     */
    private String validityEndDate;

    /**
     * 创建日期
     */
    private Date createTime;

    /**
     * 创建人ID
     */
    private String crateUserId;

    /**
     * 创建人
     */
    private String createUser;

    /**
     * 上传文件
     */
    private MultipartFile file;

    /**
     * "文件保存路径"
     */
    @TableField(exist = false)
    private String savePath;
    /**
     * "文件名"
     */
    @TableField(exist = false)
    private String fileName;

    @TableField(exist = false)
    private String accessoryTypeName;


    public enum ColName {
        accessory_id, accessory_type, upload_id, accessory_name, validity_begin_date, validity_end_date, create_time, crate_user_id, create_user,
    }
}
